package com.lqm.dao;

import com.lqm.entity.home.HomeUser;
import com.lqm.entity.home.UserAddress;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface UserAddressDao extends JpaRepository<UserAddress,Integer>, PagingAndSortingRepository<UserAddress,Integer> {
    List<UserAddress> findAllByHomeUser(HomeUser homeUser);

    @Modifying
    @Query(value = "update UserAddress h set h.status=:status where h.addressId= :#{#userAddress.addressId}")
    void setUserAddressStatus(UserAddress userAddress, int status);
    UserAddress findAllByAddressId(Integer integer);
}
